USE [ZOVNP]
GO

/****** Object:  UserDefinedFunction [dbo].[fn_GetNewOrderNumber]    Script Date: 09/28/2012 01:07:21 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
CREATE FUNCTION [dbo].[fn_GetNewOrderNumber]
(
)
RETURNS int
AS
BEGIN
	-- Declare the return variable here
	DECLARE @result int

	-- Add the T-SQL statements to compute the return value here
	SELECT @result = isnull(MAX(Number), 0) + 1 from [Order]

	-- Return the result of the function
	RETURN @result

END

GO

